Skip to content

feat(#1045): add same-package-alias lint - #1314

Merged
rultor merged 2 commits into
masterfrom
1045
Aug 27, 2026
Merged

feat(#1045): add same-package-alias lint#1314
rultor merged 2 commits into
masterfrom
1045

Conversation

@yegor256

Copy link
Copy Markdown
Member

Closes #1045.

Adds a new lint same-package-alias that catches an +alias meta whose
target object lives in the same package as the file's own +package
meta. Since the compiler auto-homes a bare reference to an object in the
same package, such an alias is redundant (see objectionary/eo#5527,
which removed all the existing ones by hand).

The parser expands a bare +alias org.eolang.txt.sprintf into the
two-part meta form sprintf Φ.org.eolang.txt.sprintf. The lint flags a
meta when the alias's fully-qualified target (with the Φ. prefix
stripped) equals <package>.<local-name>. A renamed alias
(+alias sp org.eolang.txt.sprintf) or a cross-package alias is left
alone, since neither is redundant.

What's included

  • src/main/resources/org/eolang/lints/aliases/same-package-alias.xsl — the lint
  • src/main/resources/org/eolang/motives/aliases/same-package-alias.md — motive doc
  • Five pack tests: catches the redundant case, allows a cross-package
    alias, allows a renamed same-package alias, allows an alias when no
    +package meta is present, and checks the context attribute is
    printed when line numbers are absent

Testing

  • mvn test -Dtest=LtByXslTest,PkMonoTest — 431 tests, 0 failures
  • Full mvn test -Dgroups='!deep & !benchmark' — 0 failures, 0 errors

Generated by Claude Code

claude added 2 commits August 27, 2026 06:27
Catches an `+alias` meta whose target is in the same package as the
file's own `+package` meta. Since the compiler auto-homes a bare
reference to an object of the same package, such an alias is dead
weight (see objectionary/eo#5527). A cross-package alias, or one that
renames the object to a new local name, is left alone.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwFnKcNakcpzPWb6HTQFPu
The EO parser only allows a comment before metas, not between them and
the object. The deep-tagged validatesEoPacksForErrors test caught the
resulting parse errors on CI; the fixtures didn't need the comment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwFnKcNakcpzPWb6HTQFPu
@yegor256
yegor256 marked this pull request as ready for review August 27, 2026 06:35
Copilot AI lite review requested due to automatic review settings August 27, 2026 06:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@yegor256

Copy link
Copy Markdown
Member Author

@rultor merge

@rultor

rultor commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here.

@rultor
rultor merged commit f3ed398 into master Aug 27, 2026
25 checks passed
@rultor
rultor deleted the 1045 branch August 27, 2026 14:27
@rultor

rultor commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 4min).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint not catching redundant same-package aliases

4 participants